<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@include file="./common/header.jsp" %>
<head>
	<script charset="utf-8" src="${ctx}/js/kindeditor/kindeditor-min.js"></script>
	<script charset="utf-8" src="${ctx}/js/kindeditor/lang/zh_CN.js"></script>
	<script charset="utf-8" src="${ctx}/js/kindeditor/style/complex.js"></script> 
</head>
<body>
<%@ include file="./common/top.jsp"%>
	<div class="container">

		<form class="form-horizontal" role="form" id="category_form_id">

			<input name="id" id="id_id" type="hidden" class="">


			<div class="form-group">
				<label for="" class="col-sm-2 control-label">概率</label>
				<div class="col-xs-3">
					<input name="chance" id="chance_id" type="number" required-title="概率不能为空" class="form-control required useTitle">

				</div>
			</div>

			<div class="form-group">
				<label for="" class="col-sm-2 control-label">通知标题</label>
				<div class="col-xs-3">
					<input name="noticeTitle" id="noticeTitle_id" type="text" required-title="通知标题不能为空" class="form-control required useTitle">
				</div>
			</div>

			<div class="form-group">
				<label for="" class="col-sm-2 control-label">通知内容</label>
				<div class="col-xs-3">
					<input name="noticeInfo" id="noticeInfo_id" type="hidden" id="noticeInfo_id" class="">
					<textarea name="content" id="content_id" style="width:700px;height:200px;visibility:hidden;"></textarea>
				</div>
			</div>

			<div class="form-group" style="display:none;">
				<label  class="col-sm-2 control-label">是否显示通知：</label>
				<div class="col-xs-3">

					<select name="isNotice" id="isNotice_id" class="form-control required">
						<option value="0">隐藏</option>
						<option value="1">显示</option>
					</select>
				</div>
			</div>



			<div class="form-group">
				<label for="" class="col-sm-2 control-label">第一关初始数量</label>
				<div class="col-xs-3">
					<input name="oneInit" id="oneInit_id" type="number" required-title="第一关初始数量不能为空" class="form-control required useTitle">
				</div>
			</div>

			<div class="form-group">
				<label for="" class="col-sm-2 control-label">第一关初始时间</label>
				<div class="col-xs-3">
					<input name="oneInitS" id="oneInitS_id" type="number" required-title="第一关初始时间不能为空" class="form-control required useTitle">
				</div>
			</div>

			<div class="form-group">
				<label for="" class="col-sm-2 control-label">第一关通关数量</label>
				<div class="col-xs-3">
					<input name="oneInitC" id="oneInitC_id" type="number" required-title="第一关通关数量不能为空" class="form-control required useTitle">
				</div>
			</div>

			<div class="form-group">
				<label for="" class="col-sm-2 control-label">第二关初始数量</label>
				<div class="col-xs-3">
					<input name="twoInit" id="twoInit_id" type="number" required-title="第二关初始数量不能为空" class="form-control required useTitle">
				</div>
			</div>

			<div class="form-group">
				<label for="" class="col-sm-2 control-label">第二关初始时间</label>
				<div class="col-xs-3">
					<input name="twoInitS" id="twoInitS_id" type="number" required-title="第二关初始时间不能为空" class="form-control required useTitle">
				</div>
			</div>

			<div class="form-group">
				<label for="" class="col-sm-2 control-label">第二关通关数量</label>
				<div class="col-xs-3">
					<input name="twoInitC" id="twoInitC_id" type="number" required-title="第二关通关数量不能为空" class="form-control required useTitle">
				</div>
			</div>

			<div class="form-group">
				<label for="" class="col-sm-2 control-label">第三关初始数量</label>
				<div class="col-xs-3">
					<input name="threeInit" id="threeInit_id" type="number" required-title="第三关初始数量不能为空" class="form-control required useTitle">
				</div>
			</div>

			<div class="form-group">
				<label for="" class="col-sm-2 control-label">第三关初始时间</label>
				<div class="col-xs-3">
					<input name="threeInitS" id="threeInitS_id" type="number" required-title="第三关初始时间不能为空" class="form-control required useTitle">
				</div>
			</div>

			<div class="form-group">
				<label for="" class="col-sm-2 control-label">第三关通关数量</label>
				<div class="col-xs-3">
					<input name="threeInitC" id="threeInitC_id" type="number" required-title="第三关通关数量不能为空" class="form-control required useTitle">
				</div>
			</div>



			<div class="form-group">
				<div class="col-sm-offset-2 col-sm-10">
					<button type="button" id="add_category_btn_id" class="btn btn-primary">保存</button>
					<a href="./khSetting.jsp" class="btn btn-default">取消</a>
				</div>
			</div>
		</form>
  		
	</div>
	<script>
		$(function(){ 
			var valid = new jValidation.Validation('category_form_id',{immediate:true},{onSubmit:false});
			$('#add_category_btn_id').click(
				function(){
					var result = valid.validate();
					if(!result){
						return;
					}
					var content = editor.html();
                    $("#noticeInfo_id").val(content);
					var formData = $('#category_form_id').serialize();
					jQuery.ajax( {
						type : 'POST',
						url : '../admin/khSetting/edit.do',
						dataType : 'json',
						data : formData,
						success : function(obj) {
							if(obj.result){
								window.top.jWei.Tips.success("保存数据成功");
								location.href="./khSetting.jsp";
							}else{
								window.top.jWei.Tips.success(obj.errorMsg);
							}
						},
						error : function() {
							alert('error');
						}
					});
				}		
			);
			
			var id = $.request.queryString["id"];
			jQuery.ajax( {
				type : 'Get',
				url : '../admin/khSetting/get.do',
				dataType : 'json',
				contentType : 'application/json',
				data : {
					id: id
				},
				success : function(data) {
					if(data.result){

					    for(key in data.obj) {
					        $('#'+key+'_id').val(data.obj[key]);
						}
						editor.html(data.obj.noticeInfo);
						$("#content_id").val(data.obj.noticeInfo);
					}else{
						alert(obj.errorMsg);
					}
				},
				error : function() {
					alert('error');
				}
			});
			
		});
		
		
	</script>
</body>
</html>